//
// Created by 陈成 on 2019/9/20.
//

#include "Inst.h"

Inst::Inst(uint32_t pc, sc_bv<32> inst, RegBank<REG_NUM> *r, RegBank<CSR_NUM> *csr, Mem *m) :
        r(r),
        csr(csr),
        m(m),
        pc(pc) {

}

sc_bv<32>
Inst::extendImm(sc_bv<21> imm) {
    sc_bv<32> rslt = imm.to_uint();
    for (int i = 21; i < 32; ++i) {
        rslt[i] = imm[20];
    }
    return rslt;
}

sc_bv<32>
Inst::extendImm(sc_bv<12> imm) {
    sc_bv<32> rslt = imm.to_uint();
    for (int i = 12; i < 32; ++i) {
        rslt[i] = imm[11];
    }
    return rslt;
}
